﻿@model Webcar.Entitys.BS_INSURE

@{ Layout = "~/Views/Shared/_leftPanelLayout.cshtml";}
@section LeftTree
{
     
    @{
        Html.RenderPartial("DeptTreePartialView", new Webcar.Models.DeptTreeMode { Action = "List", Controller = "Insure", ShowChild = false });
     }
}
<div style="width:600px;margin:5px 5px 5px 5px">
 @using (Html.BeginForm("Edit", "Insure", Html.ViewContext.RouteData.Values,FormMethod.Post))
{
    @Html.AntiForgeryToken()
    
    <div id="edit-car">
        @Html.HiddenFor(a => a.INSURE_NO)
        @Html.HiddenFor(a => a.CAR_NO)

        

        <table class="edit-table">
            <tr>
                <td style="width: 100px; text-align: right">*保险单号：</td>
                <td style="width: 200px">@Html.TextBoxFor(a => a.INSURE_NO2, new { @style = "width: 100%;", @onkeyup = "this.value=this.value.toUpperCase();" })</td>
                <td style="width: 100px; text-align: right">*交强险号：</td>
                <td style="width: 200px">@Html.TextBoxFor(a => a.JQX_NO, new { @style = "width: 100%;", @onkeyup = "this.value=this.value.toUpperCase();" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">*所属单位：</td>
                <td>@Html.DropDownListFor(a => a.DEPT_CODE, WebcarDataHelper.UserSuperDeptList, new { @style = "width: 100%;", @onchange = "changeDept();" })</td>
                <td style="width: 80px; text-align: right">*车辆牌照：</td>
                <td>
                    @Html.TextBox("RECORD_NO",(string)@ViewBag.RecordNO)
                </td>
            </tr>
           

            <tr>
                <td style="width: 80px; text-align: right;">厂牌型号：</td>
                <td colspan="3">@Html.TextBoxFor(a => a.FACTORY_MODLE, new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">发动机号：</td>
                <td>@Html.TextBoxFor(a => a.ENGINE_NO, new { @style = "width: 100%;" })</td>
                <td style="width: 80px; text-align: right">车辆种类：</td>
                <td>@Html.TextBoxFor(a => a.CAR_CLASS, new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 80px; text-align: right;">车架号：</td>
                <td>@Html.TextBoxFor(a => a.SHELF_NO,  new { @style = "width: 100%;" })</td>
                <td style="width: 80px; text-align: right">*保险金额：</td>
                <td>@Html.TextBoxFor(a => a.INSURE_MONEY, new { @style = "width: 100%;"})</td>
            </tr>

            <tr>
                <td style="width: 80px; text-align: right;">*初次登记日期：</td>
                <td>@Html.CalendarFor(a => a.FIRST_DATE)</td>
                <td style="width: 80px; text-align: right">已行驶里程：</td>
                <td>@Html.TextBoxFor(a => a.RUN_MILE, new { @style = "width: 100%;" })</td>

            </tr>

            <tr>
                <td style="width: 80px; text-align: right;">*开始日期：</td>
                <td>@Html.CalendarFor(a => a.START_DATE)</td>
                <td style="width: 80px; text-align: right">*结束日期：</td>
                <td>@Html.CalendarFor(a => a.END_DATE)</td>

            </tr>
        </table>


        <br />
        <div class="validation-errors">@ViewBag.ErrorMessage</div>

    </div>
    <div class="edit-button">
        @Html.DevExpress().Button(settings =>
        {
            settings.Name = "Button1";
            settings.Text = CurrentUser.CheckPermission(PermissionManager.编辑车辆保险) ? "保存" : "无权限";
            settings.Enabled = CurrentUser.CheckPermission(PermissionManager.编辑车辆保险);
            settings.UseSubmitBehavior = true;
            settings.Width = 70;
            settings.ControlStyle.CssClass = "button1";
        }).GetHtml()
        @Html.DevExpress().Button(settings =>
        {
            settings.ControlStyle.CssClass = "button2";
            settings.Name = "Button2";
            settings.Text = "取消";
            settings.Width = 70;
            settings.ClientSideEvents.Click = "function(s, e){ location.href='" + @Url.Action("List", "Insure") + "' }";

        }).GetHtml()
    </div>
    <div style="color:red">如果续保，请使用续保功能，直接修改此单据为新保单将导致原保单数据丢失。   </div>
    
    
}
</div>

<script type="text/javascript">
$(function () {
    changeDept();
    $("#RECORD_NO").change(function () {
        $("#CAR_NO").val("");
    });
    
});

function changeDept() {
    setCarAutoComplete("RECORD_NO", $("#DEPT_CODE").val(),
        '@Url.Action("GetAutoCompleteCar","Common")',
            function (event, ui) {
                $("#CAR_NO").val(ui.item.key);
                retriveCar();
            }
        );
    };

function retriveCar() {
    var select = $('#CAR_NO');
    var action = '@Url.Action("RetriveCarInfo","Common")';
    var selectCar = select.val();
    $.getJSON(action, { carNo: selectCar }, function (json) {
        $('#FACTORY_MODLE').val(json.FACTORY_MODLE);
        $('#ENGINE_NO').val(json.ENGINE_NO);
        $('#CAR_CLASS').val(json.car_class_name);
        $('#SHELF_NO').val(json.SHELF_NO);
    });
};
</script>    